import React, { useEffect } from 'react'
import { useState } from 'react'

export default function App() {
    let [person,setPerson]=useState([
        {
            id: "001",
            name: "张三"
          }, {
            id: "002",
            name: "王五"
          }, {
            id: "003",
            name: "李博"
          } 
    ])
    useEffect(()=>{
        console.log('添加成功');
    },[])

     const addPerson = () => {
        setPerson([...person,{id:Date.now(),name:'XXXX'}])
    }
  return (
    
      <div>
        <button onClick={addPerson}>按钮</button>
        {
              person.map(item => {
                return <li key={item.id}>{item.name}</li>

            })
        }
      </div>
  )
}
